<template>
  <div
    class="v-views-roomNews"
    v-loading="loading"
    element-loading-text="数据加载中..."
  >
    <div class="roomNews_title">
      <img src="@/assets/images/Roomtitle.png" class="bg_title" />
      <div class="content_title">
        <img
          src="@/assets/images/zuojiantou.png"
          @click="back"
          class="back_img"
        />
        <span class="title_name">房间入住人员档案</span>
      </div>
      <div class="roomNews-titlebody">
        <div class="principal">
          <span class="hotelName">{{ hotelInformation.hotelName }}</span>
          <!-- <template v-if="hotelInformation.hotelCity">
            {{ hotelInformation.hotelCity }}
          </template> -->
          <template v-if="hotelInformation.hotelDistrict">
            {{ hotelInformation.hotelDistrict }}
          </template>
          <template v-if="hotelInformation.hotelStreet">
            -{{ hotelInformation.hotelStreet }}
          </template>
          <template v-if="hotelInformation.hotelCommunity">
            -{{ hotelInformation.hotelCommunity }}
          </template>
          <template v-if="hotelInformation.hotelGrid">
            -{{ hotelInformation.hotelGrid }}
          </template>
          <span class="hotePernol">
            负责人：{{ hotelInformation.hotelContact }}</span
          >
          <span class="hotePernol">
            联系方式：{{ hotelInformation.hotelPhone }}</span
          >
          <span class="hotePernol">
            挂点领导：{{ hotelInformation.leader }}</span
          >
        </div>
        <el-row>
          <el-col :span="3" class="message-col">
            <span><img src="@/assets/images/fjzs.png" /> 房间总数</span>
            <span>
              <span class="color1">{{ fllor.roomTotal }}</span> 间</span
            >
          </el-col>
          <el-col :span="3" class="message-col">
            <span><img src="@/assets/images/gzry.png" /> 工作人员房间</span>
            <span>
              <span class="color2">{{ fllor.roomWork }}</span> 间</span
            >
          </el-col>
          <el-col :span="3" class="message-col">
            <span><img src="@/assets/images/yrz.png" /> 已入住</span>
            <span>
              <span class="color3">{{ fllor.roomEnter }}</span> 间</span
            >
          </el-col>
          <el-col :span="3" class="message-col">
            <span><img src="@/assets/images/zdgz.png" /> 重点关爱房间</span>
            <span>
              <span class="color4">{{ fllor.roomFocus }}</span> 间</span
            >
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="3" class="message-col">
            <span style="color:transparent">1</span>
          </el-col>
          <el-col :span="3" class="message-col">
            <span><img src="@/assets/images/glry.png" /> 隔离人员房间</span>
            <span>
              <span class="color5">{{ fllor.roomIsocial }}</span> 间</span
            >
          </el-col>
          <el-col :span="3" class="message-col">
            <span><img src="@/assets/images/wrz.png" /> 未入住</span>
            <span>
              <span class="color6">{{ fllor.roomResidue }}</span> 间</span
            >
          </el-col>
          <el-col :span="3" class="message-col">
            <span><img src="@/assets/images/qz.png" /> 重点关注房间</span>
            <span>
              <span class="color7">{{ fllor.roomDiagnosis }}</span> 间</span
            >
          </el-col>
        </el-row>
      </div>
    </div>
    <div class="roomNews_body">
      <div class="room_number">
        {{ houseData.houseName }}
        <span v-if="houseData.xssj">（已消杀：{{ houseData.xssj }} ）</span>
      </div>
      <el-tabs v-model="editableTabsValue" @tab-click="tabclick">
        <el-tab-pane
          :key="item.index"
          v-for="item in editableTabs"
          :name="item.index"
        >
          <span slot="label">
            {{ item.name }}
            <img
              src="@/assets/icon/font_yz/laoren.png"
              v-if="item.lrs"
              alt=""
              class="name_img"
            />
            <img
              src="@/assets/icon/font_yz/ertong.png"
              v-if="item.ets"
              alt=""
              class="name_img"
            />
            <img
              src="@/assets/icon/font_yz/pregnant.png"
              v-if="item.hys"
              alt=""
              class="name_img"
            />
            <img
              src="@/assets/icon/font_yz/xinli.png"
              v-if="item.xljbs"
              alt=""
              class="name_img"
            />
            <img
              src="@/assets/icon/font_yz/jcjbs.png"
              v-if="item.jcjbs"
              alt=""
              class="name_img"
            />
            <img
              src="@/assets/icon/font_yz/sdzzs.png"
              v-if="item.sdzzs"
              alt=""
              class="name_img"
            />
          </span>
          <el-steps direction="vertical" :active="active">
            <el-step>
              <div slot="icon" class="steps-icon">
                <i class="el-icon-arrow-down"></i>
                <span class="steps_icon__name"> 入境</span>
              </div>
              <div slot="description" class="describe">
                <div class="row_div">
                  <div class="rol_div">
                    <span>入境时间：</span>
                    <span class="timer">
                      {{ personData.isolateVo.entryTime }}
                    </span>
                  </div>
                </div>
              </div>
            </el-step>
            <el-step>
              <div slot="icon" class="steps-icon">
                <i class="el-icon-arrow-down"></i>
                <span class="steps_icon__name"> 转运</span>
              </div>
              <div slot="description" class="describe">
                <div class="row_div">
                  <div class="rol_div">
                    <span>转运时间：</span>
                    <span class="timer">
                      {{ personData.isolateVo.convertTime?personData.isolateVo.convertTime: changefunc(personData.isolateVo.moveDate) }}
                    </span>
                  </div>
                </div>
              </div>
            </el-step>
            <el-step>
              <div slot="icon" class="steps-icon">
                <i class="el-icon-arrow-down"></i>
                <span class="steps_icon__name"> 入住</span>
              </div>
              <div slot="description" class="describe">
                <div class="row_div">
                  <div class="rol_div">
                    <span>人员类型：</span>
                    <span class="timer">{{
                      transitionfunc(
                        'person_classify',
                        personData.isolateVo.personType
                      )
                    }}</span>
                  </div>
                  <div class="rol_div">
                    <span>基础疾病：</span>
                    <span class="timer">{{
                      personData.classify.length > 0 ? '有' : '无'
                    }}</span>
                  </div>
                  <div class="rol_div">
                    <span>心理疾病：</span>
                    <span class="timer">{{
                      personData.isolateVo.assessmentRiskLevel != '0'
                        ? '有'
                        : '无'
                    }}</span>
                  </div>
                </div>
                <div class="row_div">
                  <div class="rol_div">
                    <span>入住时间：</span>
                    <span class="timer">{{ personData.isolateVo.moveDate }}</span>
                  </div>
                  <div class="rol_div">
                    <span>工作人员：</span>
                    <span class="timer">{{
                      personData.isolateVo.creapers
                    }}</span>
                  </div>
                </div>
              </div>
            </el-step>
            <el-step>
              <div slot="icon" class="steps-icon">
                <i class="el-icon-arrow-down"></i>
                <span class="steps_icon__name"> 隔离</span>
              </div>
              <span slot="description">
                <div class="describe">
                  <el-table :data="tableData" style="width: 100%" stripe>
                    <el-table-column prop="creatime" label="观察时间">
                    </el-table-column>
                    
                    <el-table-column prop="yjzz" label="十大症状">
                      <template slot-scope="hcop">
                        {{ tabas(hcop) }}
                      </template>
                    </el-table-column>
                    <el-table-column prop="tw" label="体温"> </el-table-column>
                    <el-table-column prop="hsjg" label="核酸">
                      <template slot-scope="scope">
                        <span v-if="scope.row.hsjg == 1" class="text-green"
                          >已核酸采样</span
                        >
                        <span v-else class="text-red">未核酸采样</span>
                      </template>
                    </el-table-column>
                    <el-table-column prop="creapers" label="工作人员">
                    </el-table-column>
                  </el-table>
                  <div class="pagination_div">
                    <el-pagination
                      background
                      :page-size="form.size"
                      layout="prev, pager, next"
                      @current-change="handleCurrentChange"
                      :total="total"
                    >
                    </el-pagination>
                  </div>
                </div>
              </span>
            </el-step>
            <el-step>
              <div slot="icon" class="steps-icon">
                <i class="el-icon-arrow-down"></i>
                <span class="steps_icon__name"> 离点</span>
              </div>
              <span slot="description">
                <div class="describe">
                  <div class="row_div">
                    <div class="rol_div">
                      <span>离点时间：</span>
                      <span class="timer"></span>
                    </div>
                    <div class="rol_div">
                      <span>离点类型：</span>
                      <span class="timer"></span>
                    </div>
                    <div class="rol_div">
                      <span>工作人员：</span>
                      <span class="timer"></span>
                    </div>
                  </div>
                </div>
              </span>
            </el-step>
            <el-step>
              <div slot="icon" class="steps-icon">
                <!-- <span class="box-icon"></span> -->
                <span class="steps_icon__name"> 社区管理</span>
              </div>
              <span slot="description">
                <div class="describe">
                  <div class="row_div">
                    <div class="rol_div">
                      <span>接收时间：</span>
                      <span class="timer"></span>
                    </div>
                    <div class="rol_div">
                      <span>工作人员：</span>
                      <span class="timer"></span>
                    </div>
                  </div>
                </div>
              </span>
            </el-step>
          </el-steps>
        </el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>

<script>
import { getDict } from '@/utils';
import '@/assets/icon/font_yz/iconfont.css';
import {
  getpanelinfo,
  getpanellist,
  gettpaneldailypage,
  getAllInfo,
} from './server.js';
import {
  rollbacktwo
} from '@/utils/extract';
export default {
  data() {
    return {
      editableTabsValue: '0',
      editableTabs: [],
      loading: false,
      tableData: [],
      active: 5,
      houseId: '',
      hotelId: '',
      houseData: {},
      personData: {},
      hotelInformation: {},
      total: 0,
      fllor: {
        roomTotal: 0,
        roomWork: 0,
        roomIsocial: 0,
        roomEnter: 0,
        roomResidue: 0,
        roomFocus: 0,
        roomDiagnosis: 0,
        roomDisinfect: 0,
      },
      form: {
        size: 2,
        current: 1,
      },
    };
  },
  mounted() {
    const query = this.$route.query;
    this.houseId = query.houseId ? query.houseId : '';
    this.hotelId = query.hotelId ? query.hotelId : '';
    this.getAllInfo();
    this.getpanelinfo();
    this.getpanellist();
  },

  methods: {
    changefunc(data){
      return rollbacktwo(data)
    },
    back() {
      this.$router.go(-1);
    },
    //获取当前酒店信息
    async getAllInfo() {
      let rps = await getAllInfo(this.hotelId);
      this.hotelInformation = rps.data.data;
      this.theLayerData = rps.data.data.floorStaticalList;
      this.theLayerData.forEach((e) => {
        this.fllor.roomTotal += e.roomTotal;
      });
      this.theLayerData.forEach((e) => {
        this.fllor.roomWork += e.roomWork;
      });
      this.theLayerData.forEach((e) => {
        this.fllor.roomIsocial += e.roomIsocial;
      });
      this.theLayerData.forEach((e) => {
        this.fllor.roomEnter += e.roomEnter;
      });
      this.theLayerData.forEach((e) => {
        this.fllor.roomResidue += e.roomResidue;
      });
      this.theLayerData.forEach((e) => {
        this.fllor.roomFocus += e.roomFocus;
      });
      this.theLayerData.forEach((e) => {
        this.fllor.roomDiagnosis += e.roomDiagnosis;
      });
      this.theLayerData.forEach((e) => {
        this.fllor.roomDisinfect += e.roomDisinfect;
      });
    },
    tabclick(val) {
      this.personData = this.editableTabs[Number(val.index)];
      this.gettpaneldailypage(val);
    },
    // 获取当前房间信息
    async getpanelinfo() {
      const { data } = await getpanelinfo(this.houseId);
      this.houseData = data.data;
    },
    // 获取当前房间入住人员
    async getpanellist() {
      this.loading = true;
      const { data } = await getpanellist({
        houseId: this.houseId,
        size: 9999,
      });
      this.loading = false;
      data.data.forEach((element, index) => {
        element.index = index.toString();
      });
      this.editableTabs = data.data;
      if (data.data.length > 0) {
        this.personData = this.editableTabs[0];
        this.gettpaneldailypage(true);
      }
    },
    handleCurrentChange(val) {
      this.form.current = val;
      this.gettpaneldailypage(true);
    },
    // 获取当前人信息
    async gettpaneldailypage(val) {
      const obj = {
        ...this.form,
      };
      if (val) {
        obj.personId = this.personData.personId;
      }
      const { data } = await gettpaneldailypage({ ...obj });
      this.tableData = data.data.records;
      this.total = data.data.total;
      console.log(this.total);
    },
    transitionfunc(name_type, type) {
      if (!type) return;
      let arr = getDict(name_type);
      for (let i = 0; i <= arr.length; i++) {
        if (type == arr[i].value) {
          return arr[i].label;
        }
      }
      return '';
    },
    tabas(tab) {
      let rows = tab.row.yjzz;
      const arr = rows.split(',');
      if (arr.length === 0) return;
      let szsy = getDict('symptoms');
      let str = '';
      for (let k = 0; k < arr.length; k++) {
        for (let i = 0; i <= szsy.length - 1; i++) {
          if (arr[k] == szsy[i].value) {
            str += szsy[i].label + ',';
          }
        }
      }
      return str.slice(0, str.length - 1);
    },
  },
};
</script>

<style lang="scss" scoped>
.v-views-roomNews {
  min-height: 100vh;
  background: #f3f6fb;
  .roomNews_title {
    background: white;
    .bg_title {
      height: 83px;
    }
    .back_img {
      width: 15px;
      height: 28px;
    }
    .content_title {
      position: absolute;
      top: 30px;
      left: 30px;
      display: flex;
      justify-content: center;
      align-items: center;
      .title_name {
        color: #fff;
        font-size: 25px;
        margin-left: 20px;
        font-weight: bold;
      }
    }
    .roomNews-titlebody {
      padding: 15px 40px 15px 40px;
      .principal {
        font-size: 18px;
        font-weight: 500;
        color: #60656b;
        margin-bottom: 10px;
        .hotelName {
          font-size: 24px;
          font-weight: bold;
          color: #333333;
          margin-right: 30px;
        }
        .hotePernol {
          margin-left: 30px;
        }
      }
      .message-col {
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 18px;
        font-family: SourceHanSansCN-Medium, SourceHanSansCN;
        font-weight: 500;
        color: #60656b;
        margin-right: 7%;
        margin-top: 15px;
        width: 230px;
      }
    }
  }
  .roomNews_body {
    background: #f3f6fb;
    padding: 15px 40px;
    .room_number {
      color: #61c39d;
      border: 1px solid #61c39d;
      background: #f1fffa;
      font-size: 18px;
      font-weight: 500;
      padding: 7px 20px;
      border-radius: 6px;
    }
  }
  .steps-icon {
    position: relative;
  }

  /deep/ .el-tabs__content {
    padding-left: 90px;
    padding-top: 25px;
    .el-step__description {
      padding-right: 0;
    }
  }
  /deep/ .el-table th.is-leaf {
    background: white;
    font-size: 18px;
  }
  /deep/ .el-step:last-of-type {
    .el-step__main {
      height: 56px;
    }
    .steps_icon__name {
      left: -94px;
    }
  }
  /deep/ .el-step:first-of-type {
    .el-step__line-inner {
      border-color: #ebebeb;
    }
    .el-icon-arrow-down {
      color: #3b99ee;
    }
  }
  /deep/ .el-step__icon.is-text {
    background: #3b99ee;
    border-color: #3b99ee !important;
    box-shadow: 0px 0px 8px 0px rgba(0, 171, 213, 0.09),
      0px 0px 8px 0px rgba(90, 178, 255, 0.3);
  }
  /deep/ .el-step:last-of-type {
    .el-step__icon.is-text {
      background: white;
      border-color: white !important;
    }
  }
  /deep/ .el-step:first-of-type {
    .el-step__icon.is-text {
      background: white;
      border-color: white !important;
    }
  }
  /deep/ .el-table--striped .el-table__body tr.el-table__row--striped td {
    background: #e9f5ff;
  }
  /deep/ .el-table td,
  .el-table th {
    font-size: 18px;
  }
  /deep/ .el-tabs__item {
    font-size: 18px;
    color: #333333;
  }
  /deep/ .el-tabs__active-bar {
    background-color: #3b99ee;
  }
  /deep/ .el-tabs__item.is-active {
    color: #3b99ee;
  }
  .describe {
    position: relative;
    padding: 0 20px;
    background: #fff;
    border-radius: 6px;
    font-size: 18px;
    margin: 0 0 24px 0 !important;
    line-height: 50px;
    top: -15px;
    font-size: 18px;
    color: #999999;
    .timer {
      font-size: 18px;
      color: #666666;
    }

    .row_div {
      display: flex;
      .rol_div {
        width: 33%;
      }
    }
  }
  .steps_icon__name {
    position: absolute;
    left: -88px;
    color: #000;
    font-size: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 72px;
    text-align: right;
    font-weight: 500;
    font-size: 18px;
    font-weight: 500;
    color: #666666;
    white-space: nowrap;
  }
  .color1 {
    font-size: 24px;
    font-weight: bold;
    color: #3b99ee;
  }
  .color2 {
    font-size: 24px;
    font-weight: bold;
    color: #7c94f4;
  }
  .color3 {
    font-size: 24px;
    font-weight: bold;
    color: #61c39d;
  }
  .color4 {
    font-size: 24px;
    font-weight: bold;
    color: #ffc259;
  }
  .color5 {
    font-size: 24px;
    font-weight: bold;
    color: #ffa059;
  }
  .color6 {
    font-size: 24px;
    font-weight: bold;
    color: #8f8f8f;
  }
  .color7 {
    font-size: 24px;
    font-weight: bold;
    color: #ff8b7c;
  }
  .text-green {
    font-size: 18px;
    color: #3b99ee;
    font-weight: bold;
  }
  .text-red {
    font-size: 18px;
    color: #ff8b7c;
    font-weight: bold;
  }
  .el-icon-arrow-down {
    color: white;
  }
  .iconfont {
    color: #3b99ee;
  }
  .box-icon {
    display: inline-block;
    width: 7px;
    height: 7px;
    background: white;
    position: absolute;
    transform: translate(-50%, -50%);
  }
  .name_img {
    width: 17px;
  }
  .pagination_div {
    margin-top: 5px;
    padding-bottom: -10px;
    text-align: right;
  }
}
</style>
